#!/usr/bin/perl

use warnings;
use insj_m_network;

#This file is a small collection of tests to check for small mistakes.

#Creating a test node.
	$node = insj_m_node -> new( name => '123test' ); 

#Getting the name, resetting the name, getting the name.
	print $node ->get_name() . "\n"  ;
	      $node ->set_name('456test');
	print $node ->get_name() . "\n"  ;

#Creating a test network.
	$network = insj_m_network->new(name => "123network");
	$i = 0;
	while( $i < 10 ){
		$network ->create_node(name => $i);
		$i++;	
		}
	print "List of nodes in this network by node names: ";
	$network ->print();

#Get node name from hash
	$test =  $network->{_nodelist}->{"1"};
	print "Test node name: " . $test -> get_name() . "\n";

#Testing the iterator
	print "Testing rewinding and using the iterator.\n";
	$network->rewind;
	 while ($next = $network -> get_next() ) {
		print $next->get_name() . " ";
		}
	print "\n";

#Testing rudimentary states.
	print "Testing rudimentary states.\n";
	print "Test node name: " . $test -> get_name() . "\n";
	$test -> set_state("VirusA", 1, 2);
	$test -> set_state("VirusA", 0, 3);
	print "State Virus A: ". $test -> get_state("Virus A"). "\n";

#Testing getting a random node.
	my $node = $network->get_random_node();
	print "Randomly picked node: " . $node->get_name() . "\n";

#Printing the network;
	$network->print;

#Exporting network to Gephi
	$network->export("test.gexf","gephi");

#Testing carp non existing edge!
	$node->remove_edge("test - non existent node");

#Testing confess for false object!
	#$node->add_node("test - non existent node");

#Testing simple infection objects.
	print "Add three infections to current node.\n";
	$node->add_infection( insj_m_infection -> new(name => 'Vir_123') );
	$node->add_infection( insj_m_infection -> new(name => 'Vir_456') );
	$node->add_infection( insj_m_infection -> new(name => 'Vir_789') );	

#Iterate over infection objects.
	while ($next = $node -> get_next('infection') ) {
		print "\t".$next->get_name()."\n";
		}
